using System;
using System.Net;
using System.IO;
using System.Configuration;
using System.Collections.Specialized;
using System.Data.SqlClient;

namespace OnlinePayments
{
	/// <summary>
	/// Summary description for Dummy.
	/// </summary>
	internal class Dummy : PaymentProcessor
	{
        public Dummy(SqlConnection conn, char processorCode, int ownerID)
            : base(conn, processorCode, ownerID)
        {
        }

		public override char Authorize( CustomerInfo customerInfo, 
			Int32 transactionID, 
			decimal amount, 
			out string responseCode,
			out string responseText,
			out string AVSResult,
			out string CVV2Response,
			out string processorTransactionID,
			out string authCode 
			)
		{
			AVSResult = null;
			CVV2Response = null;
			processorTransactionID = null;
			authCode = null;
			responseCode = null;
			responseText = null;

			if ( customerInfo.CardNumber == "1111222233334444" ||
				customerInfo.CardNumber == "2222333344445559" ||
				customerInfo.CardNumber == "3333444455556664" ||
				customerInfo.CardNumber == "4444555566667774" )
			{
				responseCode = "1";
				responseText = "Authorized";
				authCode = "000001";
                return 'A'; // Authorized
			}
			else
			{
				responseCode = "2";
				responseText = "Failed";
				return 'D'; // Declined
			}
		}

		public override char Deposit( CustomerInfo customerInfo, 
			Int32 transactionID, 
			decimal amount, 
			out string responseCode,
			out string responseText,
			out string AVSResult,
			out string CVV2Response,
			out string processorTransactionID 
			)
		{
			AVSResult = null;
			CVV2Response = null;
			processorTransactionID = null;
			responseCode = null;
			responseText = null;


			if ( customerInfo.CardNumber == "1111222233334444" ||
				customerInfo.CardNumber == "2222333344445559" ||
				customerInfo.CardNumber == "3333444455556664" ||
				customerInfo.CardNumber == "4444555566667774" )
			{
				responseCode = "1";
				responseText = "Authorized";
				return 'A'; // Authorized
			}
			else
			{
				responseCode = "2";
				responseText = "Failed";
				return 'D'; // Declined
			}
		}

		public override char DepositWithPriorAuth( CustomerInfo customerInfo, 
			Int32 transactionID, 
			decimal amount, 
			string processorTransactionID,
			string authCode,
			out string responseCode,
			out string responseText
			)
		{
			responseCode = null;
			responseText = null;


			if ( customerInfo.CardNumber == "1111222233334444" ||
				customerInfo.CardNumber == "2222333344445559" ||
				customerInfo.CardNumber == "3333444455556664" ||
				customerInfo.CardNumber == "4444555566667774" )
			{
				responseCode = "1";
				responseText = "Authorized";
				return 'A'; // Accepted
			}
			else
			{
				responseCode = "2";
				responseText = "Failed";
				return 'D'; // Declined
			}
		}

		public override char Refund(CustomerInfo customerInfo,
            Int32 transactionID,
            decimal amount,
            string priorProcessorTransactionID,
            out string responseCode,
            out string responseText,
            out string processorTransactionID
			)
		{
			responseCode = null;
			responseText = null;
            processorTransactionID = string.Empty;

			if ( customerInfo.CardNumber == "1111222233334444" ||
				customerInfo.CardNumber == "2222333344445559" ||
				customerInfo.CardNumber == "3333444455556664" ||
				customerInfo.CardNumber == "4444555566667774" )
			{
				responseCode = "1";
				responseText = "Authorized";
				return 'A'; // Accepted
			}
			else
			{
				responseCode = "2";
				responseText = "Failed";
				return 'D'; // Declined
			}
		}
	}
}
